require('./dbConnect') // 数据库连接实例
//初始化一些数据
const aboutModel = require('./schema/aboutSchema') 
const bannerModel = require('./schema/bannerSchema') 
const settingModel = require('./schema/settingSchema') 
;(async function () {
  const aboutCount = await aboutModel.countDocuments()
  if (aboutCount === 0) {
    aboutModel.create({
      url: 'https://fangq.site/resume',
    })
    console.log('初始化about数据')
  }
  const bannerCount = await bannerModel.countDocuments()
  if (bannerCount === 0) {
    bannerModel.create(
        {
          midImg: '/static/images/bg1_mid.jpg',
          bigImg: '/static/images/bg1_big.jpg',
          title: '塞尔达旷野之息',
          description: '2017年年度游戏，期待续作',
          active:true,
        },
        {
          midImg: '/static/images/bg2_mid.jpg',
          bigImg: '/static/images/bg2_big.jpg',
          title: '塞尔达四英杰',
          description: '四英杰里面你最喜欢的又是谁呢',
          active:true,
        },
        {
          midImg: '/static/images/bg3_mid.jpg',
          bigImg: '/static/images/bg3_big.jpg',
          title: '日本街道',
          description: '动漫中经常出现的日本农村街道，一份独特的恬静',
          active:true,
        },
    )
    console.log('初始化banner数据')
  }
  const settingCount = await settingModel.countDocuments()
  if (!settingCount) {
    // 如果没有数据就进行初始化
    await settingModel.create({
        avatar: '/static/images/avatar.jpeg',
        siteTitle: '我的个人空间',
        github: '',
        qq: '1942343023',
        qqQrCode:
            '/static/images/qq.jpg',
        weixin: 'Jquery-qrcode',
        weixinQrCode:
            '/static/images/wx.jpg',
        mail: 'fanguoqiang@gmail.com',
        icp: '青ICP备2024001467号',
        githubName: 'Hello-fanguoqiang',
        favicon: '/static/images/favicon.jpg',
    });
    console.log("初始化全局设置数据...");
}
})()
